//package com.teangtang.fly.repository;
//
//
//import com.teangtang.fly.entity.flight;
//import org.springframework.data.jpa.repository.JpaRepository;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.query.Param;
//
//import java.util.Date;
//import java.util.List;
//
//public interface flightRepository extends JpaRepository<flight, String> {
//    @Query("SELECT f FROM flight f WHERE f.arrivalTime < :currentTime ORDER BY f.arrivalTime DESC")
//    List<flight> findFlightsBeforeCurrentTime(@Param("currentTime") Date currentTime);
//
//    default flight findClosestFlightByArrivalTime(Date currentTime) {
//        List<flight> flights = findFlightsBeforeCurrentTime(currentTime);
//        if (flights.isEmpty()) {
//            return null; // No flights found before current time
//        } else {
//            return flights.get(0); // Return the flight with the closest arrival time
//        }
//    }
//
//}
